<?php

namespace app\modules\setting\configs\seller;

use sookie\excel\SaveExcel;
use yii\db\ActiveRecord;
use sookie\react\handlers\UrlHandler;
use yii\helpers\Json;
use app\modules\setting\models\fsjl\EtcSendCreatorDetail;
use sookie\bootstraps\handlers\AuthChecker;

/**
* Class TestConfig
* @package sookie\react\configs
* app\modules\setting\configs\fsjl\FsjlConfig 模型的配置类
*/
class StoreConfig{

    /**
    * @return array
    * 获取搜索表单配置
    */
    public static function getSearchConfig(){
    return [
            [
                "component" => "FormInput",
                "field" => "shop_code",
                "label" => "店铺CODE",
                "placeholder" => "店铺CODE",
                "allowClear" => true,
            ],

    ];
    }

    /**
    * @return array
    * 获取表格的操作
    */
    public static function getTableActions(){
        return  [
        ];
    }

    /**
    * @return array
    * 获取表格行的操作
    * [] 表示要id, ["*"] 表示要一行记录,参数名record, ["id"] 指定需要的参数 ， selected_ids 表示需要所有选择的id
    * configParamsField 规定请求的时候带上数据行中的那些参数，只需要字段名
    */
    public static function getTableRowAction(){
        return [
            [
                "actionType" => "MODAL",
                "config" => [
                    "footer" => true,
                    "title" => "关联店铺",
                    "alert" => [
                        "description" => "填写以下表单修改数据模型"
                    ]
                ],
                "configUri" => UrlHandler::toAction("seller/store","update"),
                "auth" => AuthChecker::doPermissionCheck("seller/store","update"),
                "configParamsField" => ["id"],
                "label" => "关联店铺"
            ],
        ];
    }

    /**
    * @return array
    * 获取表格配置
    */
    public static function getTableConfig(){
        return [
            "rowKey" => "id",
            "columns" => [
                [
                    "title" => "图标",
                    "dataIndex" => "shop_icon",
                    "sorter" => true,
                    "key" => "shop_icon",
                    "format" => "raw",
                ],
                [
                    "title" => "店铺",
                    "dataIndex" => "shop_name",
                    "sorter" => true,
                    "key" => "shop_name",
                    "format" => "text",
                ],
            ],
            "actions" => self::getTableRowAction()
        ];
    }

    /**
    * 首页配置
    */
    public static function configIndex(){
        return [
            //搜索表单配置
            "searchConfig" => self::getSearchConfig(),
            // 操作配置 configParams 规定请求的时候带上那些参数
            "actionDivConfig" => self::getTableActions(),
            //表格配置
            "tableConfig" => self::getTableConfig(),
        ];
    }



    public static function configUpdate($model){
        return [
            "type" => "FORM",
            "formSubmitUri" => UrlHandler::toAction("seller/store","update",["id" => $model->id]),
            "config" => [
                [
                    "component" => "FormInput",
                    "field" => "shop_code",
                    "label" => "店铺编号",
                    "placeholder" => "店铺编号",
                    "allowClear" => true,
                    "initialValue" => "",
                    "rules" => [
                        [
                            "required" => true
                        ]
                    ],
                ],
            ],
        ];
    }


}

